import { Ref, inject, onMounted, onUnmounted } from "vue"
import { MainLibraryKey } from '@/types/keys'
import type { RefFunType } from '@/types/interface'

const useMainLibraryFullScreen = ()=>{
    let isMainLibraryFullScreen : Ref
    const changeMainLibraryFullScreen = ()=>{
        isMainLibraryFullScreen.value = !isMainLibraryFullScreen.value
    }

    const getMainLibraryIsFullScreen : RefFunType<Boolean> = () : Ref<Boolean> =>{
        return inject(MainLibraryKey)!
    }

    onMounted(()=>{
        isMainLibraryFullScreen = getMainLibraryIsFullScreen()
    })

    onUnmounted(()=>{
        isMainLibraryFullScreen.value = false
    })

    return { changeMainLibraryFullScreen,getMainLibraryIsFullScreen }
}

export default useMainLibraryFullScreen